package com.huyn.baseframework.utils;

import android.content.Context;

import com.umeng.analytics.MobclickAgent;

/**
 * Created by huyaonan on 16/6/12.
 */
public class UmengUtils {

    /**
     * 1. 中屏多镜头切换/中屏时点击多镜头切换/视频名，视频ID，多镜头名

     2. 全屏多镜头切换/全屏时点击镜头切换/视频名，视频ID，多镜头名

     3. 拖入小视频/将小视频拖入中视频/视频名，视频ID，多镜头名

     4. 多镜头全屏/点击右上全屏按钮/视频名，视频ID，多镜头名

     5. 参加投票/点击投票选项/选项，投票名，视频名，视频ID

     6. 参加问答/点击问答选项/选项，问答名，视频名，视频ID

     7. 参加PK/点击PK选项/选项，PK名，视频名，视频ID

     8. 出现投票/出现投票/投票名，视频名，视频ID

     9. 出现问答/出现问答/问答名，视频名，视频ID

     10. 出现PK/出现PK/PK名，视频名，视频ID

     11. 出现多镜头/出现多镜头/多镜头名，视频名，视频ID

     12. 点击设置/点击设置/视频名，视频ID

     13. 手势进退/手势进退/视频名，视频ID

     14. 拉动进度条/拉动进度条进退/视频名，视频ID

     15. 弹幕前登陆/在发弹幕前登陆成功/视频名，视频ID

     16. 发弹幕/发弹幕成功/视频名，视频ID
     */
    public static final String EVENT_SWITCH_VIDEO_IN_MIDDLE_SCREEN = "EVENT_SWITCH_VIDEO_IN_MIDDLE_SCREEN";
    public static final String EVENT_SWITCH_VIDEO_IN_FULL_SCREEN = "EVENT_SWITCH_VIDEO_IN_FULL_SCREEN";

    public static final String DRAG_VIDEO_TO_MIDDLE = "DRAG_VIDEO_TO_MIDDLE";
    public static final String TO_FULL_SCREEN = "TO_FULL_SCREEN";
    public static final String TO_VOTE = "TO_VOTE";
    public static final String TO_QA = "TO_QA";
    public static final String TO_PK = "TO_PK";
    public static final String TO_INFO = "TO_INFO";
    public static final String TO_GUESS = "TO_GUESS";

    public static final String SHOW_VOTE = "SHOW_VOTE";
    public static final String SHOW_QA = "SHOW_QA";
    public static final String SHOW_PK = "SHOW_PK";
    public static final String SHOW_INFO = "SHOW_INFO";
    public static final String SHOW_GUESS = "SHOW_GUESS";
    public static final String SHOW_MULTIVIDEO = "SHOW_MULTIVIDEO";

    public static final String TO_VIDEO_SETTING = "TO_VIDEO_SETTING";
    public static final String TO_PROCEED_OR_RECEDE_BY_GESTURE = "TO_PROCEED_OR_RECEDE_BY_GESTURE";
    public static final String TO_PROCEED_OR_RECEDE_BY_SEEKBAR = "TO_PROCEED_OR_RECEDE_BY_SEEKBAR";

    public static final String LOGIN_BEFORE_DANMU = "LOGIN_BEFORE_DANMU";
    public static final String SEND_DANMU = "SEND_DANMU";

    /**
     * 点击物品/点击物品/视频名，视频ID, 物品标题，物品ID

     加入收藏夹/点击购买按钮/视频名，物品标题，物品ID

     点击收藏夹/点击收藏夹/视频名，视频ID
     */
    public static final String CLICK_GOODS = "CLICK_GOODS";

    public static final String ADD_TO_CART = "ADD_TO_CART";

    public static final String CLICK_CART = "CLICK_CART";

    /**
     * 8.30 分享微博
     * 分享类型(img/url/video)
     */
    public static final String SHARE_VIA_WEIBO = "SHARE_VIA_WEIBO";
    public static final String SHARE_VIA_WECHAT = "SHARE_VIA_WECHAT";
    public static final String SHARE_VIA_TIMELINE = "SHARE_VIA_TIMELINE";

    /**
     * 页面

     1. 进入APP/进入APP

     2. 热更新成功/热更新成功/热更新版本号

     3. 首页进入视频/点击进入视频/视频名，视频ID

     4. 进入人物详情/进入人物详情/人物名

     5. 点击人物简介/点击简介/人物名

     6. 人物进入视频/点击进入视频/视频名，视频ID
     */
    public static final String OPEN_APP = "OPEN_APP";
    public static final String PLUGIN_UPDATE = "PLUGIN_UPDATE";
    public static final String FROM_HOME_TO_VIDEO = "FROM_HOME_TO_VIDEO";
    public static final String TO_CHARACTER = "TO_CHARACTER";
    public static final String SEE_CHARACTER_DESC = "SEE_CHARACTER_DESC";
    public static final String FROM_CHARACTER_TO_VIDEO = "FROM_CHARACTER_TO_VIDEO";

    /**
     *
     * 多镜头卡顿
     */
    public static final String MULTIVIDEO_FREEZE = "MULTIVIDEO_FREEZE";

    public static void reportUmengEvent(Context context, String id, String value) {
        try {
            if(StringUtils.isBlank(value))
                MobclickAgent.onEvent(context, id);
            else
                MobclickAgent.onEvent(context, id, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void reportUmengEvent(Context context, String id) {
        try {
            MobclickAgent.onEvent(context, id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String appendLabels(String... value) {
        if(value == null || value.length == 0)
            return "";
        StringBuffer sb = new StringBuffer();
        for(int i=0; i<value.length; i++) {
            sb.append(value[i]);
            if(i != value.length-1)
                sb.append(",");
        }
        return new String(sb);
    }

}
